<template>
	<view>
		<view class="" style="padding: 20rpx;">
			<view class="zl">
				检测订单
			</view>
			<view class="its" v-for="(item,index) in datalist" @click="godetail(item.id)">
				<view class="" style="display: flex;justify-content: space-between;align-items: center;">
					<view class="" style="color: #000000;font-size: 30rpx;">
						{{item.clinic_name}}
					</view>
					<view class="" style="color: #1262DB;font-weight: bold;font-weight: 30rpx;">
						<view class="" v-if="item.status == 3" style="color: green;">
							检测完成
						</view>
						<view class="" v-if="item.status == 1" style="color: red;">
							待支付
						</view>
						<view class="" v-if="item.status == 2" style="color: orange;">
							检测中
						</view>
						<view class="" v-if="item.status == 4" style="color: #686868;">
							已取消
						</view>

					</view>
				</view>
				<view class=""
					style="display: flex;justify-content: space-between;align-items: center;margin-top: 15rpx;">
					<view class="" style="color: #909090;font-size: 24rpx;">
						单号：{{item.order_id}}
					</view>
					<view class="" style="color: #909090;font-size: 24rpx;">
						{{item.createtime}}
					</view>
				</view>
				<view class="xian"></view>
				<view class=""
					style="display: flex;align-items: center;justify-content: space-between;font-size: 28rpx;"
					v-for="(it,idx) in item.drug_item">
					<view class="">
						{{idx + 1}}、{{it.ssued}}
					</view>
					<view class="">
						检测结果: <span v-if="it.status == 1" style="color: red;">待支付</span><span v-if="it.status == 2"
							style="color: orange;">检测中</span><span v-if="it.status == 3"
							style="color: green;">{{it.result_data}}</span><span v-if="it.status == 4"
							style="color: #686868;">已取消</span>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid: '',
				page: 1,
				datalist: []
			}
		},
		onLoad(option) {
			this.uid = option.uid
			this.getdata()
		},
		onReachBottom() {
			this.page += 1
			this.getdata()
		},
		methods: {
			godetail(id){
				uni.navigateTo({
					url:'/pages/checkorder/orderdetail?id='+id
				})
			},
			getdata() {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: this.global.url + 'api/clinic/ywyorderlist',
					method: 'POST',
					header: {
						'token': uni.getStorageSync('token')
					},
					data: {
						uid: that.uid,
						page: that.page
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							that.datalist = that.datalist.concat(result.data.data)

						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			}
		}
	}
</script>

<style>
	.its {
		padding: 20rpx;
		border: 1px solid #ccc;
		border-radius: 10rpx;
		margin-top: 30rpx;
	}

	.xian {
		border-bottom: 1px solid #e2e2e2;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.zl {
		border-left: 6rpx solid #1262DB;
		padding-left: 20rpx;
		font-weight: bold;
	}
</style>